// _Test4_Effect.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"

void example4_2(IplImage* img)
{
	cvNamedWindow("Example4-in");

	cvNamedWindow("Example4-out");
	cvShowImage("Example4-in",img);
	IplImage* out = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,3);

	cvSmooth(img,out,CV_GAUSSIAN,3,3);
	cvShowImage("Example4-out",out);

	cvReleaseImage(&out);
	cvWaitKey(0);
	cvDestroyWindow("Example4-in");
	cvDestroyWindow("Example4-out");
}


int _tmain(int argc, _TCHAR* argv[])
{
	IplImage* img = cvLoadImage("D:\\Field.jpg");
	example4_2(img);
	cvReleaseImage(&img);

	cvWaitKey(0);

	// In OpenCV 1.0 this is turn upside down ( lat nguoc lai )

	cvNamedWindow("Example4_Main",CV_WINDOW_AUTOSIZE);
	CvCapture* capture = cvCreateFileCapture("D:\\MotherEarth.avi");
	IplImage* frame;
	IplImage* frame_out, frame_out2;
	while(1)
	{
		frame = cvQueryFrame(capture);
		if(!frame)
			break;

		frame_out = cvCreateImage(cvGetSize(frame),IPL_DEPTH_8U,3);

		cvSmooth(frame,frame_out,CV_GAUSSIAN,3,3);

		cvShowImage("Example4_Main",frame_out);
		char c = cvWaitKey(33);
		if(c==27)
		break;
	}

	cvReleaseCapture(&capture);
	cvDestroyWindow("Example4_Main");
	
	return 1;
}